package cn.hesion.leetcode;
/**
 * ClassName: SortedSquares <br/>
 * Description: <br/>
 * date: 2022/5/11 6:48<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Stack;

/**
 * 977. 有序数组的平方
 * @author: hesion
 * @create: 2022-05-11 06:48
 **/
public class SortedSquares {
    public int[] sortedSquares(int[] nums) {
        List<Integer> finalArray = new ArrayList<>();
        int[] finalIntArray = new int[nums.length];
        for (int num : nums) {
            finalArray.add(squere(num));
        }
        finalArray.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        System.out.println(finalArray);
        for (int i = 0; i < finalArray.size(); i++) {
            finalIntArray[i] = finalArray.get(0);
        }
        return finalIntArray;
    }

    public int squere(int num){
        return num*num;
    }
}
